package com.lin.cloud.disk.controller;

import com.lin.cloud.disk.common.utils.Result;
import com.lin.cloud.disk.entity.request.AuthorizationPermissionRequest;
import com.lin.cloud.disk.entity.response.PermissionGroupListResponse;
import com.lin.cloud.disk.manage.IPermissionManageService;
import com.lin.cloud.disk.service.IPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Permission)表控制层
 *
 * @author ljc
 * @since 2020-12-10 16:44:59
 */
@RestController
@RequestMapping("/api/permission")
@Slf4j
@Api(tags = "权限控制器")
public class PermissionController {


    @Resource
    private IPermissionManageService permissionManageService;

    @Resource
    private IPermissionService permissionService;



    /**
     * 所有权限
     * @param
     * @return
     */
    @ApiOperation(value = "所有权限")
    @GetMapping("/allPermission")
    public Result<PermissionGroupListResponse> authorizationPermission(){
        return Result.success(permissionService.allPermissionList());
    }

    /**
     * 授权/撤销授权
     * @param request
     * @return
     */
    @ApiOperation(value = "授权/撤销授权")
    @PostMapping("/authorizationPermission")
    public Result authorizationPermission(@RequestBody @Validated AuthorizationPermissionRequest request){
        permissionManageService.authorizationPermission(request);
        return Result.success();
    }


}